<?php

include_once($cfgPaths['lib/dba'].'categoryTable.o.inc.php');

class dbaLtdCategory {

  function dbaLtdCategory (&$dba) {
     $this->dba = $dba;
  }

  function getCategoriesArrayWhere (&$result,$whereclause){
    if ($whereclause){
      $whereclause = ' where '.$whereclause;
    }
    $check  = $this->dba->query("select * from ".$this->dba->tableforwarder."_shopCat$whereclause order by name;");
    $result = $this->dba->fetch_rows_array();
    return $check;
  }

  function getCategoriesArrayFieldsWhere (&$result,$fields,$whereclause){
    $count = count($fields);
    for ($i = 0; $i < $count; $i++){
      if ($i == $count-1){
        $fieldStr .= $fields[$i];
      } else {
        $fieldStr .= $fields[$i].",";
      }
    }
    if ($whereclause){
      $whereclause = ' where '.$whereclause;
    }
    $check  = $this->dba->query("select $fieldStr from ".$this->dba->tableforwarder."_shopCat$whereclause order by name;");
    $result = $this->dba->fetch_rows_array();
    return $check;
  }

  function getVisibleCategoriesObjFields (&$check,$fields){
    $this->getVisibleCategoriesArrayFields($result,$fields);
    return new categoryTable($result);
  }

  function getVisibleCategoriesArray (&$result,$lang){
    return $this->getCategoriesArrayWhere($result,"visible = 'Y' AND lang = '$lang'");
  }

  function getVisibleCategoriesArrayFields (&$result,$fields){
     return $this->getCategoriesArrayFieldsWhere($result,$fields,"visible = 'Y'");
  }

  function getVisibleCategoriesObj ($lang){
    $this->getVisibleCategoriesArray($result,$lang);
    return new categoryTable($result);
  }

}
  
?>
